package model.forview;

import model.wrap.type.FloatElement;
import models.ConstantName;
import models.ConstantValue;

/**
 * 
 * @author pocteg
 * 
 */
public class ContentChangeFloatModelForView extends ContentForMainTemplate
{

    /**
     * ----PRIVATE-----------ATTRIBUTS-----------INSTANCE----------------------
     */

    private FloatElement floatElement;
    private String remoteAddress;
    public Long contentId;
    public String content;

    /**
     * ----PRIVATE-----------ATTRIBUTS-----------STATIC------------------------
     */

    /**
     * ----PROTECTED---------ATTRIBUTS-----------INSTANCE----------------------
     */

    /**
     * ----PROTECTED---------ATTRIBUTS-----------STATIC------------------------
     */

    /**
     * ----PUBLIC------------ATTRIBUTS-----------INSTANCE----------------------
     */

    /**
     * ----PUBLIC------------ATTRIBUTS-----------STATIC------------------------
     */

    /**
     * ----CONSTRUCTORS--------------------------------------------------------
     */

    public ContentChangeFloatModelForView()
    {

    }

    /**
     * @author pocteg
     */
    public ContentChangeFloatModelForView(FloatElement floatElement, String remoutAdress)
    {
	this.remoteAddress = remoutAdress;
	this.floatElement = floatElement;
	this.contentId = floatElement.getId();
	this.content = String.valueOf(floatElement.getContent());
	setDefaultValues();
    }

    /**
     * ----PRIVATE-----------METHOD-----------INSTANCE-------------------------
     */

    /**
     * ----PRIVATE-----------METHOD-----------STATIC---------------------------
     */

    /**
     * ----PROTECTED---------METHOD-----------INSTANCE-------------------------
     */

    /**
     * @author pocteg
     */
    private void setDefaultValues()
    {
	String title = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_TITLE);
	String header = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_HEADER);
	String footer = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_FOOTER);
	String userName = "";

	title = title != null ? title : "Редактирование контента";
	header = header != null ? header : "Редактирование контента";
	footer = footer != null ? footer : "Редактирование контента";

	mainModelForView = new MainModelForView(title, userName, header, footer);
    }

    /**
     * ----PROTECTED---------METHOD-----------STATIC---------------------------
     */

    /**
     * ----PUBLIC------------METHOD-----------INSTANCE-------------------------
     */

    /**
     * ----PUBLIC------------METHOD-----------STATIC---------------------------
     */

    /**
     * ----GETTERS--&--SETTERS-------------------------------------------------
     */

    /**
     * @author pocteg
     * @return
     */
    public String getTitleNode()
    {
	return this.floatElement.getNode().getTitle();
    }

    /**
     * @author pocteg
     * @return
     */
    public String getTitleContent()
    {
	return this.floatElement.getTitle();
    }

    /**
     * @author pocteg
     * @return
     */
    public String getIdContent()
    {
	return this.contentId.toString();
    }

    /**
     * @author pocteg
     * @return
     */
    public String getContent()
    {
	return String.valueOf(this.content);
    }

    /**
     * @author pocteg
     * @return
     */
    public String getRemouteString()
    {
	return controllers.routes.Hierarchy.getPageNodeContentChange(this.floatElement.getNode().getId().longValue(), new Integer(0)).url();
    }

}
